package com.demo.spring.formework.aop.aspect;

import com.demo.spring.formework.aop.QBMethodInvocation;

import java.lang.reflect.Method;

public class QBAfterReturningAdvice extends QBAbstractAspectJAdvice implements QBAdvise,QBMethodInterceptor {
    private QBJoinPoint joinPoint;
    public QBAfterReturningAdvice(Method aspectMethod, Object aspectTarget) {
        super(aspectMethod, aspectTarget);
    }

    public Object invoke(QBMethodInvocation mi) throws Throwable {
        Object retVal = mi.proceed();
        this.joinPoint = mi;
        this.afterReturning(retVal, mi.getMethod(), mi.getArguments(), mi.getThis());
        return retVal;
    }

    public void afterReturning(Object returnValue, Method method, Object[] args,Object target) throws Throwable{
        invokeAdviceMethod(joinPoint,returnValue,null);
    }
}
